package com.itheima.controller;

import com.itheima.service.SetmealService;
import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Setmeal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@Slf4j
@RestController("mobileSetmealController")
@RequestMapping("/setmeal")

public class SetmealController {
    @Autowired
    SetmealService setmealService;
    //获得所有套餐
    @PostMapping("/getSetmeal")
    public Result getAll(){
        ArrayList<Setmeal> resultList=setmealService.getAll();
        return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS,resultList);
    }
@PostMapping("/findById")
    public Result findById(Integer id){
    log.info("根据id查询套餐：{}", id);
    Setmeal setmeal = setmealService.finById(id);
    return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
}
}
